#include "Game.h"
// globals
#include <d3d9.h>
#include "includes.h"
#include "Box.h"
#include "Triangle.h"
#include "Circle.h"
//--------------------------------------------------------------------------------
Game::Game(HINSTANCE hInstance)
:
m_pkWindows(NULL),m_hInstance(hInstance),
renderer(NULL){
}
//--------------------------------------------------------------------------------
Game::~Game()
{

}
//--------------------------------------------------------------------------------
bool Game::StartUp()
{
	HWND hWnd=NULL;
	m_pkWindows=new Window(m_hInstance);
	
	if(!m_pkWindows){
		return false;
	}
	
	m_pkWindows->createWindow(800,600,hWnd);
		
	renderer= new Renderer(hWnd);

	timer.FirstMeasure();

	textura = Texture::ptr(new Texture("C:/Documents and Settings/el-pepi/Escritorio/svn/Motor2D/Engine/asd.bmp",255,255,255));
	renderer->LoadTexture(textura);

	sprite = new Sprite();
	sprite->SetTexture(textura);

	if (!OnStartUp())
		return false;

	return true;
}
//--------------------------------------------------------------------------------
bool Game::Loop()
{
	renderer->StartFrame();
	if (OnLoop()){
		renderer->EndFrame();
		timer.Measure();
		stringstream s;
		s<<"Engine v0.1 - FPS:"<<timer.GetFPS();
		m_pkWindows->SetWindowTitle(s.str().c_str());
		sprite->Draw(renderer);
		return true;
	}
	return false;
}
//--------------------------------------------------------------------------------
bool Game::ShutDown()
{
	if (!OnShutDown())
		return false;

	if (m_pkWindows)
		delete m_pkWindows;

	m_pkWindows = NULL;

	
	delete renderer;
	return true;
}
//--------------------------------------------------------------------------------
